package easyerp.service;

import com.baomidou.mybatisplus.extension.service.IService;
import easyerp.entity.ProductRecord;
import java.util.List;
import java.util.UUID;

public interface ProductRecordService extends IService<ProductRecord> {
    // 查询所有产品
    default List<ProductRecord> getAllProductRecords() {
        return this.list();
    }

    // 根据 ID 查询产品
    default ProductRecord getProductRecordById(UUID id) {
        return this.getById(id);
    }

    // 新增产品
    default ProductRecord insertProductRecord(ProductRecord productRecord) {
        boolean saved = this.save(productRecord);
        return saved ? productRecord : null;
    }

    // 根据 ID 更新产品
    default ProductRecord updateProductRecord(UUID id, ProductRecord productRecord) {
        productRecord.setId(id);
        boolean updated = this.updateById(productRecord);   
        return updated ? productRecord : null;
    }

    // 根据 ID 删除产品
    default void deleteProductRecord(UUID id) {
        this.removeById(id);
    }
}